home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / dev / misc / LEDA_gene.lha / LEDA-3.1c-generic / prog / graphics / polygon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-05  |  965 b   |  47 lines

  1. #include <LEDA/plane.h>
  2. #include <LEDA/window.h>
  3.  
  4. main()
  5.  
  6. { window W;
  7.  
  8.   W.init(-1000,1000,-1000);
  9.  
  10.   panel p("polygon");
  11.  
  12.   p.text_item("This program demonstrates the intersection operation  ");
  13.   p.text_item("for simple polygons (data type polygon). Use the left ");
  14.   p.text_item("mouse button to define the vertex sequence of a simple");
  15.   p.text_item("polygon P in clockwise order. Terminate the input with");
  16.   p.text_item("the middle button. Now, for each next drawn polygon Q ");
  17.   p.text_item("the intersection with P (list of polygons) is computed");
  18.   p.text_item("and displayed. Terminate the program by clicking the  ");
  19.   p.text_item("right button.");
  20.  
  21.   p.button("continue");
  22.  
  23.   p.open();
  24.  
  25.  
  26.  
  27.   polygon P,Q,R;
  28.  
  29.   W >> P;
  30.  
  31.   W.draw_polygon(P,blue);
  32.  
  33.  
  34.   W.set_mode(xor_mode);
  35.  
  36.   list<polygon> L;
  37.  
  38.   while (W >> Q)
  39.   { forall(R,L) W.draw_filled_polygon(R,red);
  40.     L = P.intersection(Q);
  41.     forall(R,L) W.draw_filled_polygon(R,red);
  42.    }
  43.  
  44.  return 0;
  45.  
  46. }
  47.